 /**
 * Description: 物资归还明细
 * @author:Hunter
 * @since:1.0.0
 *
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2018-04-08   Hunter       1.0.0     Initial
 */
package com.metro.paperless.app.service.impl;

import com.metro.core.dao.IMapper;
import com.metro.core.service.BaseServiceSupport;
import com.metro.core.service.ServiceException;
import com.metro.core.vo.ResultCode;
import com.metro.core.vo.inf.IResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.metro.paperless.app.mapper.IAppReturnDetailMapper;
import com.metro.paperless.app.service.inf.IAppReturnDetailService;
import com.metro.paperless.app.beans.vo.AppReturnDetail;

 /**
 * 物资归还明细<br>
 *
 * @author:Hunter
 * @since:1.0.0
 * @version [1.0.0, 2018-04-08]
 */
@Service("appreturndetailService")
public class AppReturnDetailService extends BaseServiceSupport<AppReturnDetail> implements IAppReturnDetailService{
    //物资归还明细Mapper
    @Autowired
    private IAppReturnDetailMapper appreturndetailMapper;

    @Override
    public IMapper getMapper() {
        return appreturndetailMapper;
    }

    @Override
    public IResult save(AppReturnDetail entity) {
        try {
            appreturndetailMapper.save(entity);
            return ResultCode.SUCCESS;
        } catch (Exception e) {
            log.error("新增物资归还明细失败", e);
            throw new ServiceException(ResultCode.ERROR);
        }
    }

    @Override
    public IResult update(AppReturnDetail entity) {
        try {
            appreturndetailMapper.update(entity);
            return ResultCode.SUCCESS;
        } catch (Exception e) {
            log.error("修改物资归还明细失败", e);
            throw new ServiceException(ResultCode.ERROR);
        }
    }

    @Override
    public IResult delete(Long id) {
        try {
            appreturndetailMapper.delete(id);
            return ResultCode.SUCCESS;
        } catch (Exception e) {
            log.error("删除失败", e);
            throw new ServiceException(ResultCode.ERROR);
        }
    }

    @Override
    public IResult deleteByIds(String ids) {
        try {
            appreturndetailMapper.deleteByIds(ids);
            return ResultCode.SUCCESS;
        } catch (Exception e) {
            log.error("删除失败", e);
            throw new ServiceException(ResultCode.ERROR);
        }
    }
}